package com.example.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pojo.SysOffice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.vo.SysOfficeVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 机构表 Mapper 接口
 * </p>
 *
 * @author lyj
 * @since 2023-02-15
 */
public interface SysOfficeMapper extends BaseMapper<SysOffice> {

    @Select("select sa.name area,so.*\n" +
            "from sys_office so \n" +
            "left join sys_area sa on so.area_id=sa.id ${ew.customSqlSegment}")
    Page<SysOfficeVo> queryByCondition(Page<SysOfficeVo> page, @Param("ew") QueryWrapper<SysOfficeVo> ew);

    @Select("select so.*\n" +
            "from sys_office so, sys_user su\n" +
            "where su.office_id=so.id\n" +
            "and su.id=#{createUserId}")
    SysOffice queryByUserId(Long createUserId);
}
